﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JScriptSuite.QA.Lib.System
{
    class NumericTests
    {
        internal static JResultItem AllTests()
        {
            return JResultItem.CreateInstance("NumericTests")
                .Push(UInt64Tests())
                .Push(IntTest())
                .Push(NullableTest())
                .Push(NullTest())
                ;
        }

        static JResultItem UInt64Tests()
        {
            UInt64 numeric = 3456677;
            object o = (UInt64)3456677;
            ulong num3 = (ulong)o;
            ulong num7 = 7ul;
            return JResultItem.CreateInstance("UInt64Tests")
                .Push(numeric.Equals(o))
                .Push(o.ToString())
                .Push(num3.ToString())
                .Push((num3 & num7) == num3)
                .Push((num3 & num7) != num3);
        }

        static JResultItem IntTest()
        {
            int i = 1;
            object o = i;
            return JResultItem.CreateInstance("IntTest")
                .Push(o is int)
                .Push(o is int?)
                .Push((int)o == 1)
                .Push(((int?)o).Value == 1)
                .Push(i.ToString())
                .Push(o.ToString())
                ;
        }

        static JResultItem NullableTest()
        {
            int? i = 1;
            object o = i;
            return JResultItem.CreateInstance("NullableTest")
                .Push(o is int)
                .Push(o is int?)
                .Push((int)o == 1)
                .Push(((int?)o).Value == 1)
                .Push((int?)o == i)
                .Push(o.ToString())
                .Push(i.ToString());

        }

        static JResultItem NullTest()
        {
            object o = null;
            return JResultItem.CreateInstance("NullTest")
                .Push(o is int)
                .Push(o is int?)
                .Push(o as int? == null)
                .Push(o as int? == 0)
                ;
        }

    }
}
